package test.solr;

import java.io.IOException;

import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.response.QueryResponse;

import com.alibaba.fastjson.JSON;

/**
 * 
 * @author Administrator
 *
 */
public class TermVector {
	
	public static void main(String[] args) {
		HttpSolrClient client = new HttpSolrClient("http://localhost:8080/solr/core2");
		SolrQuery query = new SolrQuery("*:*");
		query.setRows(2);
		query.setRequestHandler("/tvrh");
		query.setParam("tv", true);
		query.setParam("tv.all", true);
		query.setParam("tv.fl", "title");
		try {
			QueryResponse qr = client.query(query);
//			System.out.println(qr);
			System.out.println(JSON.toJSONString(qr.getResponse().asMap(Integer.MAX_VALUE), true));
			
			
		} catch (IOException e) {
			e.printStackTrace();
		} catch (SolrServerException e) {
			e.printStackTrace();
		} finally {
			try {
				client.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}
